// compoment/view/searchView/searchView.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        tabs: { // 属性名
            type: Array,
            value: []
        },
    },

    /**
     * 组件的初始数据
     */
    data: {
        activeIndex: 0,
        sliderOffset: 0,
        sliderLeft: 0
    },

    /**
     * 组件的方法列表
     */
    methods: {
        tabClick: function(e) {
            this.setData({
                sliderOffset: e.currentTarget.offsetLeft,
                activeIndex: e.currentTarget.id
            });
        },
        onLoad: function() {
            var that = this;
            wx.getSystemInfo({
                success: function(res) {
                    that.setData({
                        sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
                        sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
                    });
                }
            });
        },
        submit(e) {
            this.triggerEvent("doSearch", {
                value: e.detail,
                index: this.data.activeIndex
            })
        }
    },

})